<%@ page import="java.util.Random" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
</head>
<body>
<%
    out.println("<h2>请登录</h2>");
%>
<%
    String loginError = (String) request.getAttribute("loginError");
    if (loginError != null) {
        out.println(loginError);
    }
%>

<%--生成随机4尾数的验证码--%>
<%
    Random rand = new Random();
    int randomNum = rand.nextInt(1000,10000);
    session.setAttribute("checkNum", randomNum);
//    out.println("验证码："+session.getAttribute("checkNum"));
%>

<form action="login" method="post">
    用户名：<input type="text" id="userId" name="username" placeholder="请输入用户名" /><br><br>
    密码：<input type="password" id="pwdId" name="password" placeholder="请输入密码" /><br><br>
    验证码：<input type="text" id="checkNum" name="checkNum" placeholder="请输入验证码" /><%=session.getAttribute("checkNum")%><br><br>
    <button type="submit">登录</button><br><br>
    <a href="register.jsp">没有账号？先去注册</a>
</form>
</body>
</html>
